
#include <stdatomic.h>
#define _GNU_SOURCE
#include <dlfcn.h>

#include <stdlib.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>

#include "zeppreactor.h"
#include "zepplist.h"


void test_reactor() {
    printf("Hello, from Reactor!\n");
    struct zeppreactor *reactor = (struct zeppreactor *)malloc(sizeof(struct zeppreactor));
    zeppreactor_init(reactor);

    int sockfd = init_socket(DEFAULT_PORT);
    zeppreactor_addlistener(reactor, sockfd, accept_cb);

    zeppreactor_run(reactor);
    zeppreactor_destory(reactor);

    close(sockfd);
    getchar();
}

void test_mult_port_reactor() {
    printf("Hello, from Reactor!\n");
    struct zeppreactor *reactor = (struct zeppreactor *)malloc(sizeof(struct zeppreactor));
    zeppreactor_init(reactor);

    for (int i = 0; i < MAX_PORT; i++) {
        int sockfd = init_socket(DEFAULT_PORT + i);
        zeppreactor_addlistener(reactor, sockfd, accept_cb);
    }
    zeppreactor_run(reactor);
    zeppreactor_destory(reactor);
}

int main(int argv, char **argc) {

    test_reactor();
    // test_mult_port_reactor();
    // test_list();
    // test_list_macro();
   
    return 0;
}
